package campus.controller;

import campus.model.Subjects;
import campus.service.SubjectsService;
import campus.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author VULCAN
 * @create 2020-05-08 20:15
 * @desc 科目控制层
 **/
@RestController
@CrossOrigin
@RequestMapping("subjects")
public class SubjectsController {

    @Autowired
    private SubjectsService subjectsService;

    /**
      * @name  列表
     * @Author VULCAN
     * @Date 2020/5/8 20:23
     */
    @RequestMapping(value = "selectByExample",method = RequestMethod.GET)
    public List<Subjects> selectByExample() {
        return subjectsService.selectByExample(null);
    }

    /**
      * @name  主键id
     * @Author VULCAN
     * @Date 2020/5/8 20:23
     */
    @RequestMapping(value = "selectByPrimaryKey/{kmId}",method = RequestMethod.GET)
    public Subjects selectByPrimaryKey(@PathVariable(value = "kmId") Integer kmId) {
        return subjectsService.selectByPrimaryKey(kmId);
    }

    /**
      * @name  科目新增
     * @Author VULCAN
     * @Date 2020/5/8 20:23
     */
    @RequestMapping(value = "insert",method = RequestMethod.POST)
    public int insert(@RequestBody Subjects record) {
        return subjectsService.insert(record);
    }

    /**
      * @name  科目编辑
     * @Author VULCAN
     * @Date 2020/5/8 20:23
     */
    @RequestMapping(value = "update",method = RequestMethod.POST)
    public int updateByPrimaryKeySelective(@RequestBody Subjects record) {
        return subjectsService.updateByPrimaryKeySelective(record);
    }
    /**
     * @name  期初金额
     * @Author VULCAN
     * @Date 2020/5/8 20:23
     */
    @RequestMapping(value = "updateByPrimaryKeyBeginning",method = RequestMethod.POST)
    public int updateByPrimaryKeyBeginning(@RequestBody Subjects record) {
         return subjectsService.updateByPrimaryKeyBeginning(record);
    }
    /**
     * @name  期初数量
     * @Author VULCAN
     * @Date 2020/5/8 20:23
     */
    @RequestMapping(value = "updateByPrimaryKeyNumber",method = RequestMethod.POST)
    public int updateByPrimaryKeyNumber(@RequestBody Subjects record) {
        return subjectsService.updateByPrimaryKeyNumber(record);
    }
    /**
     * @name  成本余额
     * @Author VULCAN
     * @Date 2020/5/8 20:23
     */
    @RequestMapping(value = "updateByPrimaryKeyCost",method = RequestMethod.POST)
    public int updateByPrimaryKeyCost(@RequestBody Subjects record) {
        return subjectsService.updateByPrimaryKeyCost(record);
    }
    /**
     * @name  负债余额   权益
     * @Author VULCAN
     * @Date 2020/5/8 20:23
     */
    @RequestMapping(value = "updateByPrimaryKeyLiabilities",method = RequestMethod.POST)
    public int updateByPrimaryKeyLiabilities(@RequestBody Subjects record) {
        return subjectsService.updateByPrimaryKeyLiabilities(record);
    }
    /**
      * @name  科目主键id删除
     * @Author VULCAN
     * @Date 2020/5/8 20:24
     */
    @RequestMapping(value = "deleteByPrimaryKey/{kmId}",method = RequestMethod.DELETE)
    public int deleteByPrimaryKey(@PathVariable(value = "kmId")Integer kmId) {
        return subjectsService.deleteByPrimaryKey(kmId);
    }

    /**
     * @name  科目分页
     * @Author VULCAN
     * @Date 2020/5/8 1:10
     */
    @RequestMapping(value = "findByAllPageSize/{pageNum}/{pageSize}",method = RequestMethod.POST)
    public PageResult findByAllPageSize(@RequestBody Subjects record, @PathVariable("pageNum") int pageNum , @PathVariable("pageSize") int pageSize){
        PageResult findallpage = subjectsService.findByAllPageSize(record,pageNum, pageSize);
        return findallpage;
    }

    /**
      * @name  资产
     * @Author VULCAN
     * @Date 2020/5/9 1:37
     */
    @RequestMapping(value = "accets",method = RequestMethod.GET)
    public List<Subjects> accets() {
        return subjectsService.findByCoding1("1");
    }
    /**
     * @name 负债
     * @Author VULCAN
     * @Date 2020/5/9 0:28
     */
    @RequestMapping(value = "liabilities",method = RequestMethod.GET)
    public List<Subjects> liabilities() {
        return subjectsService.findByCoding2("2");
    }
    /**
     * @name 权益
     * @Author VULCAN
     * @Date 2020/5/9 0:28
     */
    @RequestMapping(value = "interests",method = RequestMethod.GET)
    public List<Subjects> interests() {
        return subjectsService.findByCoding3("3");
    }
    /**
     * @name 成本
     * @Author VULCAN
     * @Date 2020/5/9 0:28
     */
    @RequestMapping(value = "cost",method = RequestMethod.GET)
    public List<Subjects> cost(String kmCoding) {
        return subjectsService.findByCoding4("4");
    }
    /**
     * @name 损益
     * @Author VULCAN
     * @Date 2020/5/9 0:28
     */
    @RequestMapping(value = "profit",method = RequestMethod.GET)
    public List<Subjects> profit() {
        return subjectsService.findByCoding5("5");
    }

    @RequestMapping(value = "aa",method = RequestMethod.GET)
    public void aa() {
        subjectsService.updateXjll();
    }
}
